package com.chenl.provider.DEMOS.Quartz;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;

@Configuration
public class ScheduleConfig implements SchedulingConfigurer {

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        ThreadFactory springThreadFactory = new CustomizableThreadFactory("定时任务线程池-");
        ThreadPoolExecutor executor=new ScheduledThreadPoolExecutor(5,springThreadFactory);
        taskRegistrar.setScheduler(executor);
    }

  /*  @Bean
    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource){
        SchedulerFactoryBean factory=new SchedulerFactoryBean();
        factory.setDataSource(dataSource);
        Properties prop=new Properties();
        prop.put("org.quartz.threadPool.threadCount","20");
        prop.put("org.quartz.threadPool.threadPriority","5");
        factory.setQuartzProperties(prop);
        return factory;
    }*/
}
